package com.yt.controller;

import com.yt.entity.User;
import com.yt.util.CommonResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @Classname ProController
 * @Description
 * @Date 2021/10/31 19:07
 * @Create by 杨涛
 */
@RestController
public class ProController {

    @Value("${server.port}")
    private String port;
    public static HashMap<Long,User> hm=new HashMap<>();
    static {
        hm.put(1L,new User(1,"u1","u1"));
        hm.put(2L,new User(2,"u2","u2"));
        hm.put(3L,new User(3,"u3","u3"));
    }

    @RequestMapping("/get/{id}")
    public CommonResult<User> getUserById(@PathVariable("id")  long id){
        return new CommonResult<>(200,
                "get by id "+port,hm.get(id));
    }

}
